#ifndef TrackingTask_H
#define TrackingTask_H


//!Includes

#include  "../driver/DriverGnuPlot.h"
#include  "../algorithms/Segmentation.h"
#include  "../algorithms/Target.h"
#include "../algorithms/OutputHandler.h"

#include "Aria.h"
#include "ArNetworking.h"
#include <cv.h>
#include <cxcore.h>
#include <highgui.h>

//!Defines
#define PBVS 1
#define IBVS 2
#define FROMCAM 1
#define FROMSERVER 2
#define NEWTARGET 1
#define PREDEFTARGET1 2
#define PREDEFTARGET2  3
#define PREDEFTARGET3  4

//!Global Functions


namespace tasks
{

/**
 * class TrackingTask
 *
 * Autor:David Bevilaqua
 *
 * DESCRIPTION:
 *
 */

class TrackingTask
{
public:

	//!Enums



	//!Constructors/Destructors

	/**
	 * Empty Constructor
	 */
	TrackingTask ( );

	/**
	 * Empty Destructor
	 */

	~TrackingTask ( );

	//!Public Attributes
	bool m_bNewVect;
	bool m_bFillVect;



	//!Public Accessor Methods
	ArClientBase* GetArClient();
	void SetArClient(ArClientBase* client);
	void GetImage(int val);
	void SetReference(int val);
	std::vector <algorithms::Target> GetInterpoledVector( );
	std::vector <algorithms::Target> GetTargetVector( );

	//!Public Methods

	void ShowDestinImage(int t,std::string string);
	void ShowSourceImage(int t,std::string string);
	void ShowRoiImage(int t,std::string string);
	void ReleaseDestinImage( );
	void ReleaseSourceImage( );
	void ReleaseRoiImage( );
	void FindTarget( );
	void ClearBuffer( );
	void FindTargetPoints( );
	void FillTarget(int val);
	void DestroyWindow(std::string string );
	void CreateWindow(std::string string );


protected:

	//!Protected Attributes



	//!Protected Methods



private:

	//!Private Attributes

	IplImage *m_pSourceImage;
	IplImage *m_pDestinImage;
	IplImage *m_pRoi;
	CvCapture* m_pCapture;
	ArClientBase* m_pClient;
	CvBox2D m_TargetBox;
	std::vector <algorithms::Target> m_TargetVector;
	std::vector <CvPoint> m_TargetPointsTemp;
	algorithms::Target m_Reference;
	algorithms::Segmentation m_Segmentation;
	algorithms::OutputHandler *m_pOutput;
	int  m_iCountBuffer;
	int  m_iCountTarget;
	int  m_iCountMaxTarget;
	bool m_bFindTarget;
	bool m_bFindTargetPoints;


	//!Private Methods

	void initAttributes ( );
	void SetRoi(CvPoint point1,CvPoint point2);
};

};

#endif
